ServerEvents.recipes((event) => {
    let RegisteredFormula = (heat, fuel, item, itemcount, fluid1, fluid2) => {
        event.recipes.custommachinery.custom_machine("eou:blast_furnace/controller", 200)
            .requireStructure([[
                "ABA",
                "DBD",
                "ACA",
            ], [
                "ABA",
                "B B",
                "AmA",
            ], [
                "ABA",
                "B B",
                "ABA",
            ], [
                " B ",
                "B B",
                " B ",
            ], [
                " B ",
                "BEB",
                " B ",
            ]
            ], {
                "A": "createindustry:fireproof_brick_reinforcement",
                "B": "createindustry:fireproof_bricks",
                "C": "eou:blast_furnace/fuel_port",
                "D": "eou:blast_furnace/exportation_port",
                "E": "eou:blast_furnace/feed_port"
            })
            .requireFunctionToStart((ctx) => {
                let level = ctx.block.minecraftLevel
                let pos = ctx.block.getPos()
                let facing = ctx.getBlock().getProperties().get("facing")
                //控制器其他机器相对坐标
                let ports_pos = { fuel: [0, -1, 0], exportation1: [-1, -1, -1], exportation2: [1, -1, -1], feed: [0, 3, -1] }
                let ports = global.getothermachine(pos, ports_pos, facing, level)
                if (ports["fuel"].getFluidStored("heat").amount >= heat
                    && ports["fuel"].getItemStored("fuel").count >= fuel
                    && ports["feed"].getItemStored("ore_mixture").getId() == item
                    && ports["feed"].getItemStored("ore_mixture").count >= itemcount
                    && (ports["exportation1"].getFluidStored("fluid1").getId() == fluid1.getId()
                        || ports["exportation1"].getFluidStored("fluid1").getId() == "minecraft:empty")
                    && (ports["exportation2"].getFluidStored("fluid1").getId() == fluid2.getId()
                        || ports["exportation2"].getFluidStored("fluid1").getId() == "minecraft:empty")
                    && ports["exportation1"].getFluidStored("fluid1").amount <= 10000 - fluid1.amount
                    && ports["exportation2"].getFluidStored("fluid1").amount <= 10000 - fluid2.amount
                ) {
                    ports["fuel"].removeItemFromSlot("fuel", fuel, false);
                    ports["feed"].removeItemFromSlot("ore_mixture", itemcount, false);
                    return Result.success()
                }
                return Result.error("underfeed")
            })
            .requireFunctionEachTick((ctx) => {
                let level = ctx.block.minecraftLevel
                let pos = ctx.block.getPos()
                let facing = ctx.getBlock().getProperties().get("facing")
                //控制器其他机器相对坐标
                let ports_pos = { fuel: [0, -1, 0], exportation1: [-1, -1, -1], exportation2: [1, -1, -1], feed: [0, 3, -1] }
                let ports = global.getothermachine(pos, ports_pos, facing, level)
                if (ports["fuel"].getFluidStored("heat").amount >= heat) {
                    return Result.success()
                }
                return Result.error("underfuel")
            })
            .requireFunctionOnEnd((ctx) => {
                let level = ctx.block.minecraftLevel
                let pos = ctx.block.getPos()
                let facing = ctx.getBlock().getProperties().get("facing")
                //控制器其他机器相对坐标
                let ports_pos = { fuel: [0, -1, 0], exportation1: [-1, -1, -1], exportation2: [1, -1, -1], feed: [0, 3, -1] }
                let ports = global.getothermachine(pos, ports_pos, facing, level)
                ports["exportation1"].addFluidToTank("fluid1", fluid1, false)
                ports["exportation2"].addFluidToTank("fluid1", fluid2, false)
                return Result.success()
            })
            .resetOnError()
            .jei()
            .produceFluid(fluid1, "fluid1")
            .produceFluid(fluid2, "fluid2")
            .requireItem(Item.of(item, itemcount), "ore_mixture")
            .requireItem(Item.of("createindustry:coal_coke_dust", fuel), "fuel")
            .requireFluid(Fluid.lava(heat), "heat")
    }
    RegisteredFormula(8000, 4, "minecraft:iron_ingot", 1, Fluid.of("eou:molten_cast_iron", 144), Fluid.of("createindustry:carbon_dioxide", 1000))
    RegisteredFormula(8000, 4, "createdeco:cast_iron_ingot", 1, Fluid.of("eou:molten_steel", 144), Fluid.of("createindustry:carbon_dioxide", 1000))
    for (let i in global.mineral) {//矿物溶液
        RegisteredFormula(8000, 1, "eou:" + global.mineral[i] + "_mixture", 1, Fluid.of("eou:molten_" + global.mineral[i], 72), Fluid.of("createindustry:carbon_dioxide", 1000))
    }
})